package com.heima.stroke.handler.valuation;

public class BasicValuation implements Valuation {
    private Valuation valuation;

    public BasicValuation(Valuation valuation){
        this.valuation = valuation;
    }

    @Override
    public float calculation(float km) {
        // 基础计费逻辑：如果传入了装饰器，则调用装饰器的计算方法；否则返回0
        if (valuation != null) {
            return valuation.calculation(km);
        }
        // 基础价格，比如起步价
        float basePrice = 10.0f;
        // 每公里单价
        float perKilometerPrice = 2.0f;
        
        // 计算总费用
        return basePrice + (km > 0 ? km * perKilometerPrice : 0);
    }
}
